<template>
  <div class="content_box">
    <div class="main-box">
      <p class="main-title">请输入驳回理由</p>

      <el-form ref="ruleFormRef" :model="ruleForm" :rules="rules">
        <el-form-item label="驳回理由" prop="notes">
          <el-input v-model="ruleForm.notes" type="textarea" placeholder="请输入驳回理由！"/>
        </el-form-item>
        <el-form-item>
          <div class="dialog-footer">
            <el-button @click="close">取消</el-button>
            <el-button :loading="submitLoading" :disabled="submitLoading" type="primary" @click="onSubmit">确认驳回</el-button>
          </div>
        </el-form-item>
      </el-form>
      
    </div>
  </div>
</template>
<script setup lang="ts">
import { reactive, ref, computed,onMounted } from "vue";
import { ElNotification } from "element-plus";
import { return_to_applicant } from "@/api/bond/refund";

const props = defineProps({
  bailId: {
    type: Number,
  },
  processId: {
    type: Object,
  },
});

onMounted(() => {
});

const emit = defineEmits(['closeDrawer','changeSubmit']);


// 关闭
const close=()=>{
  emit("closeDrawer",false);
}

// 确认
const ruleFormRef = ref();
let submitLoading = ref(false)
let ruleForm = ref(
  {notes:''}
)
const rules = reactive({
  notes: [
  { required: true, message: '请输入驳回理由！', trigger: 'blur' },
  ],
});
const onSubmit=async()=>{
  await ruleFormRef.value.validate();
  let data = {
    bail_id:props.bailId,
    process_id:props.processId,
    notes:ruleForm.value.notes
  }
  submitLoading.value = true
  await return_to_applicant(data).then(res=>{
    if (res.code == 1) {
      setTimeout(() => {
        emit("closeDrawer",true);
        ElNotification({ message: '已驳回', type: "success" });
      }, 500);
    }else{
      ElNotification.error(res.msg);
      submitLoading.value = false
    }
  })
  // emit("changeSubmit",obj);
  // close()
}
</script>
<style scoped lang="scss">
.dialog-footer {
  width: 100%;
  margin-top:50px;
  text-align: center;
}
.main-box{
  min-height: auto;
  ::v-deep .el-dialog__header{
      padding:0
  }
}
.main-text{
  margin:20px 0 47px 0;
  font-size: 14px;
  color: #323C4F;
}

.list{
  border-radius: 8px;
  background: #F8F8F8;
  border: 1px solid #EAEAEA;
  padding:10px 18px;
  margin-top:17px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .box{
    div{
    display: flex;
      line-height: 34px;
      p{
        font-size: 14px;
        color: #3D3D3D;
        &:first-child{
          width: 130px;
        }
      }
    }
  }
  
  .quan{
    width: 16px;
    height: 16px;
    border: 1px solid #D8D8D8;
    border-radius: 50%;
    margin-right:8px;
    &.on{
      background: #1C55D1;
      border-color:#1C55D1;
      display: flex;
      align-items: center;
      justify-content: center;
      span{
        display: inline-block;
        width: 6px;
        height: 6px;
        background: #fff;
        border-radius: 50%;
      }
    }
  }
}
</style>
  